<?php
/*
 * 内部链接
 * */
class inlink_links{
	public $G;
	public function __construct(&$G){
		$this->G = $G;
	}

	public function _init(){
		$this->dbpdo=$this->G->loadclass('dbpdo');
		$this->routes = $this->G->loadclass('routes');
		$this->tpl = $this->G->loadclass('tpl');
	}
	
	public function getAll(){
		return $this->dbpdo->query("inlink",'*',"","","link_level desc");
	}
	
	public function getOneLinkByID($IntID){
		return $this->dbpdo->getOne("inlink",'*',array('id'=>$IntID));
	}
	
	public function save($dsw){
		return $this->dbpdo->insert_data("inlink",$dsw);
	}
	
	public function update($dsw=array(),$condition=array()){
		return $this->dbpdo->update_data("inlink",$dsw,$condition);
	}
	
	public function isview($IntID){
		$Strok="";
		$list=$this->dbpdo->getOne("inlink",'*',array('id'=>$IntID));
		if($list['isview']==0){
			$row=array(
				'endtime'=>time(),
				'enduser'=>$_SESSION['tinwinsession']['uid'],
				'isview'=>1
			);
			$Strok='<span class="glyphicon glyphicon-eye-open"></span>';
		}else{
			$row=array(
				'endtime'=>time(),
				'enduser'=>$_SESSION['tinwinsession']['uid'],
				'isview'=>0
			);
			$Strok='<span class="glyphicon glyphicon-eye-close"></span>';
		}
		$this->dbpdo->update_data("inlink",$row,array('id' => $IntID));
		return $Strok;
	}
	
	public function del($IntID){
		return $this->dbpdo->remove("inlink",array("id"=>$IntID));
	}
}
?>
